/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Formularios;

import Atributos.DadosStatic;
import Metodos.MinimizaTela;
import Metodos.ObjetoMet;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;

/**
 *
 * @author Andre
 */
public class Aguarde extends javax.swing.JFrame {
static int i;
static int quantresg;
ObjetoMet objmet=new ObjetoMet();
MinimizaTela tela= new MinimizaTela();  
    /**
     * Creates new form Aguarde
     */
    public Aguarde() {
         
        initComponents();
        BufferedImage image=null;
        File imageFile=new File(".\\src\\Imagens\\logo3.png");
        try {
            image=ImageIO.read(imageFile);
            
        } catch (IOException ex) {
        }
        this.setIconImage(image);
        
        i=0;
        
        try {
            tela.Minimiza(1);
        } catch (SQLException ex) {
            Logger.getLogger(EscolherRelatorio.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            objmet.atualiza_id_gerar(0);
        } catch (SQLException ex) {
            Logger.getLogger(Aguarde.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        timer1 = new org.netbeans.examples.lib.timerbean.Timer();
        jPanel1 = new javax.swing.JPanel();
        jSeparator1 = new javax.swing.JSeparator();
        jl_serie = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();

        timer1.addTimerListener(new org.netbeans.examples.lib.timerbean.TimerListener() {
            public void onTime(java.awt.event.ActionEvent evt) {
                timer1OnTime(evt);
            }
        });

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("SGH");
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosed(java.awt.event.WindowEvent evt) {
                formWindowClosed(evt);
            }
        });

        jPanel1.setBackground(new java.awt.Color(0, 0, 0));
        jPanel1.setLayout(null);

        jSeparator1.setBackground(new java.awt.Color(255, 153, 0));
        jSeparator1.setForeground(new java.awt.Color(0, 0, 0));
        jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);
        jPanel1.add(jSeparator1);
        jSeparator1.setBounds(31, 10, 10, 180);

        jl_serie.setBackground(new java.awt.Color(0, 0, 0));
        jl_serie.setFont(new java.awt.Font("D3 Euronism italic", 1, 18)); // NOI18N
        jl_serie.setForeground(new java.awt.Color(255, 255, 255));
        jl_serie.setText("<html>Aguarde o Horario ser gerado ou\n<br> as dependencias surgirem.\n</html>");
        jPanel1.add(jl_serie);
        jl_serie.setBounds(50, 50, 480, 80);

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/gerar.jpg"))); // NOI18N
        jLabel1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabel1MouseClicked(evt);
            }
        });
        jPanel1.add(jLabel1);
        jLabel1.setBounds(190, 130, 200, 50);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 586, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 235, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-565)/2, (screenSize.height-240)/2, 565, 240);
    }// </editor-fold>//GEN-END:initComponents

    private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
        objmet.Deleta10Haulas();
        try {
            tela.Minimiza(0);
        } catch (SQLException ex) {
            Logger.getLogger(Aguarde.class.getName()).log(Level.SEVERE, null, ex);
        }
       

  java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                new ChamaLayout().setVisible(true);
            }
        });     
    }//GEN-LAST:event_formWindowClosed

    private void jLabel1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel1MouseClicked
        if(i==0){
           timer1.start();
          
          jLabel1.setVisible(false);
          
          setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
          java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                    Horario horario = new Horario();
            }
        });
          
      i=1;
      }
    }//GEN-LAST:event_jLabel1MouseClicked

    private void timer1OnTime(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_timer1OnTime
        int id = 0;
        try {
            id = objmet.buscaid_gerar();
        } catch (SQLException ex) {
            Logger.getLogger(Aguarde.class.getName()).log(Level.SEVERE, null, ex);
        }
        if(id==1){
           
            dispose();
             timer1.stop();
        }
    }//GEN-LAST:event_timer1OnTime

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Aguarde.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Aguarde.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Aguarde.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Aguarde.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                new Aguarde().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JLabel jl_serie;
    private org.netbeans.examples.lib.timerbean.Timer timer1;
    // End of variables declaration//GEN-END:variables

    
}
